package com.zmkj.Controller;

import com.zmkj.domain.SysWord;
import com.zmkj.service.Imp.SysCourseServiceImp;
import com.zmkj.service.Imp.SysUserServiceImp;
import com.zmkj.service.Imp.SysWorkServiceImp;
import com.zmkj.utils.Rest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping
public class IndexController {

    @Autowired
    private SysUserServiceImp sysUserServiceImp;
    @Autowired
    private SysCourseServiceImp sysCourseServiceImp;
    @Autowired
    private SysWorkServiceImp sysWorkServiceImp;

    @GetMapping("/userData/{userid}")
    public Rest UserData(@PathVariable(name = "userid") Integer id){
        return sysUserServiceImp.GetUserData(id);
    }

    @GetMapping("/CourseData/{userid}")
    public Rest CourseData(@PathVariable(name = "userid") Integer id){
        return sysCourseServiceImp.GetCourseData(id);
    }


    @GetMapping("/DeleteCourse/{CourseId}/{userId}")
    public Rest DeleteCourse(@PathVariable(name = "CourseId") Integer courseId,@PathVariable(name = "userId") Integer userId){
        return sysCourseServiceImp.DeleteCourse(courseId,userId);
    }

    @PostMapping("/AddWord")
    public Rest AddWord(@RequestBody SysWord sysWord){
        System.out.println(sysWord);
        return sysWorkServiceImp.AddWordData(sysWord);
    }


    @GetMapping("/GetWorkData/{userId}")
    public Rest getworkdata(@PathVariable("userId") Integer userid){
        return sysWorkServiceImp.getWordData(userid);
    }

    @GetMapping("/GetUserData/{userId}")
    public Rest getUserData(@PathVariable("userId") Integer userId){
        return sysUserServiceImp.getAllUserData(userId);
    }

}
